package com.tenton.controller;


import com.tenton.entity.User;
import com.tenton.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author td
 * @since 2022-04-07
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;
    
    @PostMapping("/add")
    public boolean addUser(@RequestBody User user){
        return userService.insertUser(user);
    }
    
    @PutMapping("/update")
    public boolean updateUser(@RequestBody User user){
        return userService.updateUser(user);
    }
    
    @DeleteMapping("/delete")
    public boolean deleteUser(@RequestParam("id") Integer id){
        return userService.deleteUser(id);
    }
    
    @GetMapping("/getById")
    public User getById(@RequestParam("id") Integer id){
        return userService.getById(id);
    }
    
    @GetMapping("/getAll")
    public List<User> getAll(){
        return userService.getAll();
    }
}
